package system.servlet;

import java.io.IOException;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.Region;

import system.base.Customer;
import system.base.ProductCategory;
import system.base.Warehouse;
import system.base.WarehouseCategory;
import system.base.WarehouseCategoryRelation;

import com.apep.jwcs.service.AirSortReportExcel;
import com.apep.jwcs.service.AirSortReportService;
import com.hitrust.gs.bean.GSProductApepBean;
import com.hitrust.gs.bean.GSProviderBean;
import com.hitrust.gs.dao.GSMonthInfoDao;
import com.hitrust.gs.dao.GSProviderDAO;
import com.hitrust.gs.lib.GSAutoAuditongDateConfigurator;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.util.ResponseUtils;
import com.hitrust.gs.util.exception.GSException;

import framework.core.ConstDefine;
import framework.core.DBConnection;
import framework.core.DBEngine;
import framework.core.DBResult;
import framework.core.DateUtil;
import framework.core.LogWriter;
import framework.core.ObjectList;
import framework.core.SrvContext;
import framework.core.StringUtil;
import framework.core.UniversalRow;
import framework.core.UniversalTable;

public class ReportTaxMessage extends HttpServlet {
	private static final long serialVersionUID = 1;// 仅为不让本类出现警告 unnecessary
	private static final String IS_REPORT_PROCESSING = "isReportProcessing";

	public void init(ServletConfig aConfig) throws ServletException {
		super.init(aConfig);
	}

	

	/** 开始执行报表 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException {
		if (!isProcessContinue(request, response)) {
			return;
		}

		HttpSession session = request.getSession();
		session.setAttribute(IS_REPORT_PROCESSING, Boolean.TRUE);

		System.out.println("**ReportServlet start**");
		/** 时间拼接 开始************************************************** */
		String tDateString = new DateUtil().getFullString();
		String tYear = tDateString.substring(0, 4);
		String tMonth = tDateString.substring(5, 7);
		String tDate = tDateString.substring(8, 10);
		String tHour = tDateString.substring(11, 13);
		String tMin = tDateString.substring(14, 16);
		String tSec = tDateString.substring(17, 19);
		String fileName = "GW_REPORT_" + tYear + "_" + tMonth + "_" + tDate
				+ "_" + tHour + "_" + tMin + "_" + tSec;
		/** 时间拼接 结束************************************************** */

		/** 基础变量设置 开始************************************************* */
		String providerName = ""; // 供应商名称
		String inCustomerName = ""; // 供货单位名称
		String customerCode = ""; // 领料单位编码
		// String warehouseProduct = ""; //报表分类 此变量 使用地不明确 暂注释
		String getCustomers = "";// 领料单位
		String title = request.getParameter("title");
		String warehouseCode = ""; // 仓库编码
		String start = ""; // 查询起始时间
		String end = ""; // 查询终止时间
		String needAll = "";// 查询所有的纪录
		String wstr="";
		/** 基础变量设置 结束************************************************* */

		/**
		 * title : 1.压库产品进、销、存报表 2.领用报表 3.压库产品进、销、存资金汇总月报 4.压库产品应付款月报
		 * 5.买断产品资金进出累计汇总（成本价） 6.合并库收料清单（修理公司） 7.压库产品分类月进出明细
		 * 8.买断产品资金进出累计汇总(账本分类统计) 10.买断产品进销存报表（因为9被用掉了） 16.空调报表(11-15下面有被用掉)
		 * 18.产品进销存供应商分类报表,19供应商结算分类明细报表，20，供应商结算分类总汇报表
		 */
		/** 压库产品进销存报表 对供应商参数进行判断 开始 */
		if ("1".equals(title) || "10".equals(title) || "18".equals(title)
				|| "19".equals(title)) {
			if (!"".equals(request.getParameter("providerName"))
					&& request.getParameter("providerName") != null) {
				try {
					providerName = request.getParameter("providerName");
					providerName = SrvContext.fixString(providerName);
				} catch (Exception e) {
					providerName = "";
				}
			} else {
				providerName = "";
			}
			needAll = request.getParameter("needAll");
		}
		
		if (!"".equals(request.getParameter("warehouseCode"))
				&& request.getParameter("warehouseCode") != null) {
			warehouseCode = request.getParameter("warehouseCode");
		}
		String querytype = request.getParameter("querytype");
		String month = "";
		/** 压库产品进销存报表 对查询时间段进行判断 开始 */
		int sYear = 0;
		int sMonth = 0;
		if ("1".equals(querytype)) {
			String yearMonth = request.getParameter("begindate") + "-"
					+ request.getParameter("enddate");
			sYear = Integer.parseInt(request.getParameter("begindate").trim());
			sMonth = Integer.parseInt(request.getParameter("enddate").trim());
			int sDate = 31; // 每月的默认天数
			try {
				sDate = DateUtil.getMaxDayOfMonth(sYear, sMonth);
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
			start = yearMonth + "-01";
			end = yearMonth + "-" + String.valueOf(sDate);
			if (String.valueOf(sMonth - 1).length() < 2) {
				month = String.valueOf(sYear) + "0"
						+ String.valueOf(sMonth - 1);
			} else {
				month = String.valueOf(sYear + sMonth);
			}
		} else {
			start = request.getParameter("begindate");
			if ("".equals(request.getParameter("enddate"))) {
				end = new framework.core.DateUtil().getDateString();
			} else {
				end = request.getParameter("enddate");
			}
			int tmpMonth = Integer.parseInt(start.substring(6, 7)) - 1;

			if (String.valueOf(tmpMonth).length() < 2) {
				month = start.substring(0, 4);
				month += "0" + String.valueOf(tmpMonth);
			} else {
				month = start.substring(0, 4);
				month += String.valueOf(tmpMonth);
			}
		}

		/** 压库产品进销存报表 对查询时间段进行判断 结束 */
		String before_end = "";
		// start += " 00:00:00";
		// end += " 23:59:59";

		String endHour = null;// 带时间点的期初计算
		if (start.length() <= 10) {
			start += " 00:00:00";
		} else {
			endHour = start.substring(10, start.length());
		}
		if (end.length() <= 10) {
			end += " 23:59:59";
		} else {
			endHour = start.substring(10, start.length());
		}

		before_end = start;
		String title1 = ""; // 表头
		String warehouseName = ""; // 仓库名称
		ObjectList warehouseList = ObjectList.getList();
		try {
			DBConnection con = null;
			con = DBConnection.open(false);
			warehouseName = Warehouse.fetchByCode(con, warehouseCode).getName();
			if (warehouseCode.length() == 8) {
				warehouseList = Warehouse.fetchWarehouses(con, warehouseCode);
			}
			con.close();
		} catch (Exception e2) {
			System.out.println(e2.getMessage());
		}
		String startType2 = "";// 按日期查时 起始时间
		String endType2 = "";
		boolean isType2 = false;// 如果是选择日期
		int startDay = Integer.parseInt(start.substring(8, 10));

		GSMonthInfoDao gmi = new GSMonthInfoDao();
		int superMonth = Integer.parseInt(start.substring(5, 7)) - 1;
		int year = Integer.parseInt(start.substring(0, 4));
		if (superMonth == 0) {
			superMonth = 12;
			year = year - 1;
		}
		String dataMonth = "" + year + "-"
				+ (superMonth > 9 ? "" + superMonth : "0" + superMonth);
		String nextMonth = "" + year + "-" + start.substring(5, 7);

		// LogWriter.info("月结开始" + start + "至" + end);
		String ws[]=warehouseCode.split(",");
		try {
			DBConnection con = null;
			con = DBConnection.open(false);
			warehouseName = Warehouse.fetchByCode(con, ws[0]).getName();
			for(int i=1;i<ws.length;i++){
				warehouseName +=","+ Warehouse.fetchByCode(con, ws[1]).getName();

			}
			List ls =new ArrayList();
			for(int i=0;i<ws.length;i++){
				if(ws[i].length()==6){
					ObjectList wss=Warehouse.fetchAllOrgs(con, ws[i]);
					if(wss!=null&&wss.size()>0){
						for(int ii=0;ii<wss.size();ii++){
							Warehouse w=(Warehouse)wss.get(ii);
							if(w.getCode().equals(ws[i])==false){
								ls.add(w.getCode());
							}
						}
					}
				}else{
					ls.add(ws[i]);
				}
			}
			
				String ws1[]=new String[ls.size()];
				for(int ii=0;ii<ls.size();ii++){
					ws1[ii]=""+ls.get(ii);
				}
				ws=ws1;
			
			
			con.close();
		} catch (Exception e2) {
			System.out.println(e2.getMessage());
		}
		
		boolean isAvaliable = true;// 是否保存成功
		boolean isLager = false;// 是否数据过多

		/**
		 * 压库产品进销存 数据提取 开始 (9是新的查询逻辑,不同之处是月结的查询) (10是买断产品进销存) (16是空调报表)
		 * 17是按集团分类进销存报表)
		 */
		

		 if ("1".equals(title) || "9".equals(title) || "10".equals(title)
				|| "18".equals(title) || "19".equals(title)) {
			String masterStart = "";
			String masterEnd = "";
			String masterPart1Start = "";
			String masterPart1End = "";
			String in = "";
			String out = "";
			String newMonthStorage = "";
			Vector vec2 = new Vector();
			String balance_mode = request.getParameter("balanceMode");
			String position = request.getParameter("positionCode");
			if (GSBaseConstants.PLANPRICE.equals("true")) {
				title1 = warehouseName + "仓库产品进、销、存报表";
			} else {
				if ("18".equals(title)) {
					title1 = warehouseName + "开票信息报表";
					
			         if(ws.length==1){
			        	 wstr="'"+ws[0]+"'";
			         }else{
			        	 wstr="('"+ws[0]+"'";
			        	 for(int i=1;i<ws.length;i++){
			        		 wstr+=",'"+ws[i]+"'";
			        	 }
			        	 wstr+=")";
			         }
				} else if ("19".equals(title)) {
					title1 = warehouseName + "仓库供应商结算分类明细报表";
				} else if (balance_mode.equals("1")) {
					title1 = warehouseName + "仓库产品压库进、销、存报表";
				} else if (balance_mode.equals("")) {
					title1 = warehouseName + "仓库产品库进、销、存报表";
				}
			}

			/** 按供应商提取出入库明细 */
			int totalSize = 0;

			Vector vec1 = new Vector();
			String all = null;

			DBConnection con = null;
			DBResult dbrs = null;
			ResultSet rs = null;
			// 获取供应商编码
			String psql = "select code from t_provider where name='"+providerName+"' ";
			String pCode="";
			String tj = "";
			try {
					
					
					con = DBConnection.open(false);
					dbrs = DBEngine.doSelect(con, psql);
					rs = dbrs.getRs();
					while (rs.next()) {
						pCode = rs.getString("code");
						
					}
					if(pCode!=null&&!pCode.equals("")){
						tj= " and b2.provider_code='"+pCode+"' ";
					}
					if (balance_mode.equals("0")) {
						/*
						 * all=
						 * "select b1.*,b2.name,b2.product_unit,b2.model,b2.spec,b2.unit_price,b3.code_edition,b3.tax_type,b4.customer_name,b4.customer_tax,b4.customer_address,b4.customer_phone,b4.customer_band,b4.customer_user from("
						 * +
						 * "select product_code,product_price,company_code,sum(count1) count1,sum(money) money from ("
						 * +
						 * "select a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6)  company_code, SUM(a2.product_count) count1,sum(a2.product_money) money from t_out_head a1,t_out_sub a2 where "
						 * +
						 * "a1.out_bill_code=a2.out_bill_code and a2.status='1' and a1.status='1' and a2.balance_mode='1' and a1.warehouse_code like '"
						 * +warehouseCode+"%' and out_time>='"+start+
						 * "' and out_time<='"+end+
						 * "'  group by a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6) "
						 * + "union all "+
						 * "select a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6)  company_code, SUM(a2.product_count)count1,sum(a2.product_money) money from t_in_head a1,t_in_sub a2 where "
						 * +
						 * "a1.in_bill_code=a2.in_bill_code and a2.status='1' and a1.status='1' and a2.balance_mode='2' and a1.warehouse_code like '"
						 * +warehouseCode+"%' and in_time>='"+start+
						 * "' and in_time<='"+end+
						 * "'   group by a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6) "
						 * +
						 * ") group by product_code,product_price,company_code) b1,t_product b2,t_product_tax b3,t_company_message b4 "
						 * +
						 * "where b1.product_code=b2.concentricity_code and b1.product_code=b3.product_code and b1.company_code=b4.warehouse_code "
						 * ;
						 */
						all = "select * from ("
								+ "select b1.*,b2.name,b2.product_unit,b2.model,b2.spec,b2.unit_price,b3.name as provider_name from("
								+ "select product_code,product_price,company_code,sum(count1) count1,sum(money) money from ("
								+ "select a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6)  company_code, SUM(a2.product_count) count1,sum(a2.product_money) money from t_out_head a1,t_out_sub a2 where "
								+ "a1.out_bill_code=a2.out_bill_code and a2.status='1' and a1.status='1' and a2.balance_mode='1' "
								+ "and a1.warehouse_code in "
								+ wstr
								+ " and out_time>='"
								+ start
								+ "' and out_time <='"
								+ end
								+ "'   group by a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6) "
								+ "union all "
								+ "select a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6)  company_code, SUM(a2.product_count)count1,sum(a2.product_money) money from t_in_head a1,t_in_sub a2 where "
								+ "a1.in_bill_code=a2.in_bill_code and a2.status='1' and a1.status='1' and a2.balance_mode='2' "
								+ "and a1.warehouse_code in "
								+ wstr
								+ " and in_time>='"
								+ start
								+ "' and in_time <='"
								+ end
								+ "' group by a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6) "
								+ ") group by product_code,product_price,company_code) b1,t_product b2,t_provider b3 "
								+ "where b1.product_code=b2.concentricity_code and b2.status='1' and b3.status='1' and b3.code = b2.provider_code "+tj+" ) c1 left join t_product_tax b3 on c1.product_code=b3.product_code "
								+ "left join t_company_message b4 on c1.company_code=b4.warehouse_code order by c1.provider_name ";
					} else if (balance_mode.equals("1")) {
						all = "select * from ("
								+ "select b1.*,b2.name,b2.product_unit,b2.model,b2.spec,b2.unit_price,b3.name as provider_name from("
								+ "select product_code,product_price,company_code,sum(count1) count1,sum(money) money from ("
								+ "select a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6)  company_code, SUM(a2.product_count) count1,sum(a2.product_money) money from t_out_head a1,t_out_sub a2 where "
								+ "a1.out_bill_code=a2.out_bill_code and a2.status='1' and a1.status='1' and a2.balance_mode='1' "
								+ "and a1.warehouse_code in "
								+ wstr
								+ " and out_time>='"
								+ start
								+ "' and out_time <='"
								+ end
								+ "'  group by a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6) "
								+ ") group by product_code,product_price,company_code) b1,t_product b2,t_provider b3 "
								+ "where b1.product_code=b2.concentricity_code and b2.status='1' and b3.status='1' and b3.code = b2.provider_code "+tj+" ) c1 left join t_product_tax b3 on c1.product_code=b3.product_code "
								+ "left join t_company_message b4 on c1.company_code=b4.warehouse_code order by c1.provider_name ";
					} else if (balance_mode.equals("2")) {
						all = "select * from ("
								+ "select b1.*,b2.name,b2.product_unit,b2.model,b2.spec,b2.unit_price,b3.name as provider_name from("
								+ "select product_code,product_price,company_code,sum(count1) count1,sum(money) money from ("
								+ "select a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6)  company_code, SUM(a2.product_count)count1,sum(a2.product_money) money from t_in_head a1,t_in_sub a2 where "
								+ "a1.in_bill_code=a2.in_bill_code and a2.status='1' and a1.status='1' and a2.balance_mode='2' "
								+ "and a1.warehouse_code in "
								+ wstr
								+ " and in_time>='"
								+ start
								+ "' and in_time <='"
								+ end
								+ "' group by a2.product_code,a2.product_price,substr(a1.warehouse_code,1,6) "
								+ ") group by product_code,product_price,company_code) b1,t_product b2,t_provider b3 "
								+ "where b1.product_code=b2.concentricity_code and b2.status='1' and b3.status='1' and b3.code = b2.provider_code "+tj+" ) c1 left join t_product_tax b3 on c1.product_code=b3.product_code "
								+ "left join t_company_message b4 on c1.company_code=b4.warehouse_code order by c1.provider_name ";
					}
					dbrs = DBEngine.doSelect(con, all);
					rs = dbrs.getRs();

					while (rs.next()) {
						totalSize++;
						String[] values = new String[16];
						values[9] = rs.getString("customer_name");
						values[10] = rs.getString("customer_tax");
						String address = rs.getString("customer_address");
						String phone = rs.getString("customer_phone");
						if (address == null) {
							address = "";
						}
						if (phone == null) {
							phone = "";
						}
						if(address.equals("") && phone.equals("")){
							values[11]="";
						}else{
						values[11] = address + "（" + phone + "）";
						}
						String band = rs.getString("customer_band");
						String user = rs.getString("customer_user");
						if (band == null) {
							band = "";
						}
						if (user == null) {
							user = "";
						}
						if(band.equals("") && user.equals("")){
							values[12]="";
						}else{
						values[12] = band + "（" + user + "）";
						}
						values[1] = rs.getString("name");
						values[6] = rs.getString("product_unit");
						values[7] = rs.getString("count1");
						values[8] = rs.getString("money");
						values[13] = rs.getString("code_edition");
						values[14] = rs.getString("tax_type");
						values[15] = rs.getString("provider_name");
						values[0] = rs.getString("product_code");
						values[2] = rs.getString("company_code");
						values[4] = rs.getString("spec");
						String model = rs.getString("model");
						String spec = rs.getString("spec");
						if (model == null) {
							model = "";
						}
						if (spec == null) {
							spec = "";
						}
						if(model.equals("") && spec.equals("")){
							values[3]="";
						}else{
						values[3] = spec + "（" + model + "）";
						}
						values[5] = rs.getString("unit_price");
						vec1.add(values);
					}
				
				vec2.add(vec1);
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				try {
					if (rs != null) {
						rs.close();
					}
				} catch (SQLException e) {
					e.printStackTrace();
				}
				try {
					if (dbrs != null) {
						dbrs.clear();
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				try {
					if (con != null) {
						con.close();
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			if (!isAvaliable) {
				isAvaliable = false;
			} else if (totalSize > 13000) {
				isAvaliable = false;
				isLager = true;
			} else {
				if ("18".equals(title)) {
					writeExcel_ReportYKProductAll(month, title, fileName, vec2,
							title1, start, end, warehouseCode, request,
							response);
				}
			}
		}
		
		   
		// 封装数据并返回给客户端
		// 判断报表生成的结果
		if (!isAvaliable) {
			if (isLager) {
				request.getSession().setAttribute("MSG", "数据量过于巨大，请缩小查询值的范围");
			} else {
				request.getSession().setAttribute("MSG", "没有查到数据,请重新输入查询条件");
			}
			try {
				String path = "";
				if ("1".equals(title)) {
					path = "/system/report/ReportProductMS.jsp";
				} else if ("2".equals(title)) {
					path = "/system/report/ReportCustomer.jsp";
				} else if ("3".equals(title)) {
					path = "/system/report/ReportYKProductMonthNew.jsp";
				} else if ("4".equals(title)) {
					path = "/system/report/ReportYKMoneyMonth.jsp";
				} else if ("5".equals(title)) {
					path = "/system/report/ReportMDMoneyInout.jsp";
				} else if ("6".equals(title)) {
					path = "/system/report/ReportCustomerInList.jsp";
				} else if ("7".equals(title)) {
					path = "/system/report/ReportYKProductMonthList.jsp";
				} else if ("8".equals(title)) {
					path = "/system/report/ReportMDWCMoneyInout.jsp";
				} else if ("9".equals(title)) {
					path = "/system/report/ReportYKProductNew.jsp";
				} else if ("10".equals(title)) {
					path = "/system/report/ReportProductMS.jsp";
				} else if ("11".equals(title)) {
					path = "/system/report/ReportMDMoneyInoutNew.jsp";
				} else if ("12".equals(title)) {
					path = "/system/report/ReportYKProductMonthListNew.jsp";
				} else if ("13".equals(title)) {
					path = "/system/report/ReportCustomerMS.jsp";
				} else if ("14".equals(title)) {
					path = "/system/report/ReportAllWarehouseMoneyMonthSum.jsp";
				} else if ("16".equals(title)) {
					path = "/system/report/ReportAirProduct.jsp";
				} else if ("17".equals(title)) {
					path = "/system/report/ReportCustomerMS.jsp";
				} else if ("18".equals(title)) {
					path = "/system/report/ReportTaxMessage.jsp";
				} else if ("19".equals(title)) {
					path = "/system/report/ReportProviderProductType.jsp";
				} else if ("20".equals(title)) {
					path = "/system/report/ReportProviderProductTypAll.jsp.jsp";
				} else if ("21".equals(title)) {
					path = "/system/report/ReportProductRepair.jsp";
				} else if ("22".equals(title) || "23".equals(title)) {
					path = "/system/report/ReportRepair.jsp";
				}

				getServletConfig().getServletContext()
						.getRequestDispatcher(path).forward(request, response);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		session.setAttribute(IS_REPORT_PROCESSING, Boolean.FALSE);
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException {
		doPost(request, response);
	}

	

	

	

	

	
	//文本
	private HSSFCell createCell(HSSFWorkbook aWb, HSSFRow aRow, short column,
			String alaValueue) {
		HSSFCellStyle contextStyle = aWb.createCellStyle();
		HSSFDataFormat format = aWb.createDataFormat();
		contextStyle.setDataFormat(format.getFormat("@"));
		HSSFCell tCell = aRow.createCell(column);
		tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
		tCell.setCellStyle(contextStyle);
		tCell.setCellValue(alaValueue);
		tCell.setCellType(HSSFCell.CELL_TYPE_STRING);
		return tCell;
	}
	//整数
	private HSSFCell createCell2(HSSFWorkbook aWb, HSSFRow aRow, short column,
			String alaValueue) {
		HSSFCellStyle contextStyle = aWb.createCellStyle();
		//contextStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
		HSSFCell tCell = aRow.createCell(column);
		tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
		tCell.setCellStyle(contextStyle);
		tCell.setCellValue(Double.parseDouble(alaValueue));
		return tCell;
	}
	//2位小数
	private HSSFCell createCell3(HSSFWorkbook aWb, HSSFRow aRow, short column,
			String alaValueue) {
		HSSFCellStyle contextStyle = aWb.createCellStyle();
		//contextStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));
		HSSFCell tCell = aRow.createCell(column);
		tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
		tCell.setCellStyle(contextStyle);
		tCell.setCellValue(Double.parseDouble(alaValueue));
		return tCell;
	}

	private HSSFCell createCell(HSSFWorkbook aWb, HSSFRow aRow, short column,
			String aValue, short aAlign, boolean border) {
		HSSFCell tCell = aRow.createCell(column);
		tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
		tCell.setCellValue(aValue);
		HSSFCellStyle tCellStyle = aWb.createCellStyle();
		tCellStyle.setAlignment(aAlign);
		tCellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		if (border) {
			tCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
			tCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
			tCellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
			tCellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
			tCellStyle.setBottomBorderColor(HSSFColor.BLACK.index);
			tCellStyle.setTopBorderColor(HSSFColor.BLACK.index);
			tCellStyle.setRightBorderColor(HSSFColor.BLACK.index);
			tCellStyle.setLeftBorderColor(HSSFColor.BLACK.index);
		}
		tCell.setCellStyle(tCellStyle);
		return tCell;
	}

	

	

	

	/** 供应商内部类 */
	class ProviderTemp {
		// 供应商编码
		public String providerCode = "";
		// 供应商名称
		public String ProviderName = "";
		public ObjectList listOut = null;
		public ObjectList listIn = null;
		public ObjectList list = null;
	}

	/** 在一个月中 已给出时间 最早start,最终得到 本月的第一天和早于start的最晚时间 */
	private String[] getBeforetime(String start) {
		String[] strs = new String[] { "9999-99-99 99:99:99",
				"0000-00-00 00:00:00" };
		StringBuffer beforeStart = new StringBuffer(start);
		StringBuffer beforeEnd = new StringBuffer(start);
		beforeStart = beforeStart.replace(8, 10, "01");
		int day = Integer.parseInt(String.valueOf(start.subSequence(8, 10)));
		if (day > 1) {
			day--;
		} else {
			return strs;
		}
		String strDay = null;
		if (day < 10) {
			strDay = "0" + day;
		} else {
			strDay = String.valueOf(day);
		}
		beforeEnd = beforeEnd.replace(8, 10, strDay);
		String str1 = String.valueOf(beforeStart);
		String str2 = String.valueOf(beforeEnd);
		strs[0] = str1 + " 00:00:00";
		strs[1] = str2 + " 23:59:59";
		return strs;
	}

	

	

	

	/** 将总集合分割 以product_type为分隔条件 */
	private List splitProductType(List vec) {
		if (vec == null || vec.size() == 0) {
			return null;
		}
		int allSize = vec.size();
		List newVec = new ArrayList();
		List splitVec = new ArrayList();
		boolean needNew = false;
		for (int i = 1; i < allSize; i++) {
			if (needNew) {
				splitVec = new Vector();
				needNew = false;
			}
			String[] values1 = (String[]) vec.get(i);
			String[] values2 = null;
			if (allSize != i + 1) {
				splitVec.add(values1);

			} else {
				splitVec.add(values1);
				newVec.add(splitVec);
			}
		}
		return newVec;
	}

	

	

	private boolean isProcessContinue(HttpServletRequest request,
			HttpServletResponse response) {
		String action = request.getParameter("action");

		if (IS_REPORT_PROCESSING.equalsIgnoreCase(action)) {
			String val = request.getParameter("val");
			HttpSession session = request.getSession();
			Boolean isReportProcessing = (Boolean) session
					.getAttribute(IS_REPORT_PROCESSING);
			if (isReportProcessing == null) {
				isReportProcessing = Boolean.FALSE;
			}
			String jsonString = "{result:" + isReportProcessing.booleanValue()
					+ ",val:" + val + "}";
			ResponseUtils.renderJson(response, jsonString);
			return false;
		} else {
			return true;
		}
	}

	private void errorMessage(HttpServletRequest request,
			HttpServletResponse response, String title, String message)
			throws ServletException {
		try {
			String path = "";
			if ("1".equals(title)) {
				path = "/system/report/ReportProductMS.jsp";
			} else if ("2".equals(title)) {
				path = "/system/report/ReportCustomer.jsp";
			} else if ("3".equals(title)) {
				path = "/system/report/ReportYKProductMonthNew.jsp";
			} else if ("4".equals(title)) {
				path = "/system/report/ReportYKMoneyMonth.jsp";
			} else if ("5".equals(title)) {
				path = "/system/report/ReportMDMoneyInout.jsp";
			} else if ("6".equals(title)) {
				path = "/system/report/ReportCustomerInList.jsp";
			} else if ("7".equals(title)) {
				path = "/system/report/ReportYKProductMonthList.jsp";
			} else if ("8".equals(title)) {
				path = "/system/report/ReportMDWCMoneyInout.jsp";
			} else if ("9".equals(title)) {
				path = "/system/report/ReportYKProductNew.jsp";
			} else if ("10".equals(title)) {
				path = "/system/report/ReportProductMS.jsp";
			} else if ("11".equals(title)) {
				path = "/system/report/ReportMDMoneyInoutNew.jsp";
			} else if ("12".equals(title)) {
				path = "/system/report/ReportYKProductMonthListNew.jsp";
			} else if ("13".equals(title)) {
				path = "/system/report/ReportCustomerMS.jsp";
			} else if ("14".equals(title)) {
				path = "/system/report/ReportAllWarehouseMoneyMonthSum.jsp";
			} else if ("16".equals(title)) {
				path = "/system/report/ReportAirProduct.jsp";
			} else if ("17".equals(title)) {
				path = "/system/report/ReportCustomerMS.jsp";
			} else if ("18".equals(title)) {
				path = "/system/report/ReportTaxMessage.jsp";
			} else if ("19".equals(title)) {
				path = "/system/report/ReportProviderProductType.jsp";
			} else if ("20".equals(title)) {
				path = "/system/report/ReportProviderProductTypeAll.jsp";
			} else if ("21".equals(title)) {
				path = "/system/report/ReportProductRepair.jsp";
			} else if ("22".equals(title) || "23".equals(title)) {
				path = "/system/report/ReportRepair.jsp";
			}

			request.getSession().setAttribute("MSG", message);
			getServletConfig().getServletContext().getRequestDispatcher(path)
					.forward(request, response);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/** EXCEL 处理 报表18 */
	private void writeExcel_ReportYKProductAll(String month, String title,
			String fileName, Vector vec, String title1, String start,
			String end, String warehouseCode, HttpServletRequest request,
			HttpServletResponse response) {
		ServletOutputStream out = null;
		try {
			/** 创建通用EXCEL 开始 */
			HSSFWorkbook tWb = new HSSFWorkbook();
			Region region = null;
			HSSFSheet tSheet = null;
			HSSFRow tRow = null;
			HSSFCell c0 = null;
			HSSFCell c1 = null;
			HSSFCell c2 = null;
			HSSFCell c3 = null;
			HSSFCell c4 = null;
			HSSFCell c5 = null;
			HSSFCell c6 = null;
			HSSFCell c7 = null;
			HSSFCell c8 = null;
			HSSFCell c9 = null;
			HSSFCell c10 = null;
			HSSFCell c11 = null;
			HSSFCell c12 = null;
			HSSFCell c13 = null;
			HSSFCell c14 = null;
			HSSFCell c15 = null;
			HSSFCell c16 = null;
			HSSFCell c17 = null;
			HSSFCell c18 = null;
			HSSFCell c19 = null;
			HSSFCell c20 = null;
			HSSFCell c21 = null;
			HSSFCell c22 = null;
			HSSFCell c23 = null;
			HSSFCell c24 = null;
			HSSFCell c25 = null;
			HSSFCell c26 = null;
			HSSFCell c27 = null;
			HSSFCell c28 = null;
			HSSFCell c29 = null;
			HSSFCell c30 = null;
			HSSFCell c31 = null;
			HSSFCell c32 = null;
			HSSFCell c33 = null;
			HSSFCell c34 = null;
			HSSFCell c35 = null;
			HSSFCell c36 = null;
			HSSFCell c37 = null;
			HSSFCell c38 = null;
			HSSFCell c39 = null;
			HSSFCell c40 = null;
			HSSFCell c41 = null;
			HSSFCell c42 = null;
			HSSFCell c43 = null;
			HSSFCell c44 = null;
			HSSFCell c45 = null;
			HSSFFont font = tWb.createFont();
			font.setFontHeightInPoints((short) 9);
			font.setFontName("宋体");
			font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			HSSFCellStyle cStyle = tWb.createCellStyle();
			cStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
			HSSFCellStyle cStyleM = tWb.createCellStyle();
			cStyleM.setAlignment(HSSFCellStyle.ALIGN_CENTER);
			cStyleM.setFont(font);
			HSSFCellStyle cStyleM_R = tWb.createCellStyle();
			cStyleM_R.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
			cStyleM_R.setFont(font);
			/** 创建通用EXCEL 结束 */

			/** 创建Sheet 开始 */
			tSheet = tWb.createSheet();

			tWb.setSheetName(0, "开票信息报表", HSSFCell.ENCODING_UTF_16);
			tSheet.setColumnWidth((short) 0, (short) (16 * 256));
			tSheet.setColumnWidth((short) 1, (short) (16 * 256));
			tSheet.setColumnWidth((short) 2, (short) (22 * 256));
			tSheet.setColumnWidth((short) 3, (short) (22 * 256));
			tSheet.setColumnWidth((short) 4, (short) (22 * 256));
			tSheet.setColumnWidth((short) 5, (short) (10 * 256));
			tSheet.setColumnWidth((short) 6, (short) (10 * 256));
			tSheet.setColumnWidth((short) 7, (short) (10 * 256));
			tSheet.setColumnWidth((short) 8, (short) (12 * 256));
			tSheet.setColumnWidth((short) 9, (short) (16 * 256));
			tSheet.setColumnWidth((short) 10, (short) (16 * 256));
			tSheet.setColumnWidth((short) 11, (short) (16 * 256));
			tSheet.setColumnWidth((short) 12, (short) (16 * 256));
			tSheet.setColumnWidth((short) 13, (short) (16 * 256));
			tSheet.setColumnWidth((short) 14, (short) (16 * 256));
			tSheet.setColumnWidth((short) 15, (short) (16 * 256));
			tSheet.setColumnWidth((short) 16, (short) (16 * 256));
			tSheet.setColumnWidth((short) 17, (short) (16 * 256));
			tSheet.setColumnWidth((short) 18, (short) (16 * 256));
			tSheet.setColumnWidth((short) 19, (short) (16 * 256));
			tSheet.setColumnWidth((short) 20, (short) (16 * 256));
			tSheet.setColumnWidth((short) 21, (short) (16 * 256));
			tSheet.setColumnWidth((short) 22, (short) (16 * 256));
			tSheet.setColumnWidth((short) 23, (short) (16 * 256));
			tSheet.setColumnWidth((short) 24, (short) (16 * 256));
			tSheet.setColumnWidth((short) 25, (short) (16 * 256));
			tSheet.setColumnWidth((short) 26, (short) (16 * 256));
			tSheet.setColumnWidth((short) 27, (short) (16 * 256));
			tSheet.setColumnWidth((short) 28, (short) (16 * 256));
			tSheet.setColumnWidth((short) 29, (short) (16 * 256));
			tSheet.setColumnWidth((short) 30, (short) (16 * 256));
			tSheet.setColumnWidth((short) 31, (short) (16 * 256));
			tSheet.setColumnWidth((short) 32, (short) (16 * 256));
			tSheet.setColumnWidth((short) 33, (short) (16 * 256));
			tSheet.setColumnWidth((short) 34, (short) (16 * 256));
			tSheet.setColumnWidth((short) 35, (short) (16 * 256));
			tSheet.setColumnWidth((short) 36, (short) (16 * 256));
			tSheet.setColumnWidth((short) 37, (short) (16 * 256));
			tSheet.setColumnWidth((short) 38, (short) (16 * 256));
			tSheet.setColumnWidth((short) 39, (short) (16 * 256));
			tSheet.setColumnWidth((short) 40, (short) (16 * 256));
			tSheet.setColumnWidth((short) 41, (short) (16 * 256));
			tSheet.setColumnWidth((short) 42, (short) (16 * 256));
			tSheet.setColumnWidth((short) 43, (short) (16 * 256));
			tSheet.setColumnWidth((short) 44, (short) (16 * 256));
			// tSheet.setColumnWidth((short) 11, (short) (14 * 256));

			// 标题行
			tRow = tSheet.createRow((short) 0);
			c0 = createCell(tWb, tRow, (short) 5, title1);
			c0.setCellStyle(cStyleM);
			// 日期行
			tRow = tSheet.createRow((short) 1);
			region = new Region(1, (short) 9, 1, (short) 13);
			tSheet.addMergedRegion(region);
			createCell(tWb, tRow, (short) 9, "               " + start + " 至 "
					+ end, HSSFCellStyle.ALIGN_CENTER, false);

			// 表头行
			tRow = tSheet.createRow((short) 2);
			// c0 = createCell(tWb, tRow, (short) 11, "");
			c1 = createCell(tWb, tRow, (short) 0, "发票种类");
			c2 = createCell(tWb, tRow, (short) 1, "单据号");
			c3 = createCell(tWb, tRow, (short) 2, "单据日期");
			c4 = createCell(tWb, tRow, (short) 3, "客户编号");
			c5 = createCell(tWb, tRow, (short) 4, "客户名称");
			c6 = createCell(tWb, tRow, (short) 5, "客户税号");
			c7 = createCell(tWb, tRow, (short) 6, "客户地址电话");
			c8 = createCell(tWb, tRow, (short) 7, "客户银行及账号");
			c9 = createCell(tWb, tRow, (short) 8, "备注");
			c10 = createCell(tWb, tRow, (short) 9, "专用发票红票通知单号");
			c11 = createCell(tWb, tRow, (short) 10, "普通发票红票对应正数发票代码");
			c12 = createCell(tWb, tRow, (short) 11, "普通发票红票对应正数发票号码");
			c13 = createCell(tWb, tRow, (short) 12, "开通人");
			c14 = createCell(tWb, tRow, (short) 13, "复核人");
			c15 = createCell(tWb, tRow, (short) 14, "收款人");
			c16 = createCell(tWb, tRow, (short) 15, "销方银行及账号");
			c17 = createCell(tWb, tRow, (short) 16, "销方地址电话");
			c18 = createCell(tWb, tRow, (short) 17, "商品编号");
			c19 = createCell(tWb, tRow, (short) 18, "名称");
			c20 = createCell(tWb, tRow, (short) 19, "规格型号");
			c21 = createCell(tWb, tRow, (short) 20, "计量单位");
			c22 = createCell(tWb, tRow, (short) 21, "数量");
			c23 = createCell(tWb, tRow, (short) 22, "含税金额");
			c24 = createCell(tWb, tRow, (short) 23, "税率");
			c25 = createCell(tWb, tRow, (short) 24, "税额");
			c26 = createCell(tWb, tRow, (short) 25, "折扣金额");
			c27 = createCell(tWb, tRow, (short) 26, "折扣税额");
			c28 = createCell(tWb, tRow, (short) 27, "无税单价");
			c29 = createCell(tWb, tRow, (short) 28, "折扣率");
			c30 = createCell(tWb, tRow, (short) 29, "收货人");
			c31 = createCell(tWb, tRow, (short) 30, "收货人纳税人识别号");
			c32 = createCell(tWb, tRow, (short) 31, "发货人");
			c33 = createCell(tWb, tRow, (short) 32, "发货人纳税人识别号");
			c34 = createCell(tWb, tRow, (short) 33, "起运地、经由、到达地");
			c35 = createCell(tWb, tRow, (short) 34, "车种车号");
			c36 = createCell(tWb, tRow, (short) 35, "车船吨位");
			c37 = createCell(tWb, tRow, (short) 36, "运输货物信息");
			c38 = createCell(tWb, tRow, (short) 37, "编码版本号");
			c39 = createCell(tWb, tRow, (short) 38, "税收分类编码");
			c40 = createCell(tWb, tRow, (short) 39, "是否享受优惠政策");
			c41 = createCell(tWb, tRow, (short) 40, "享受税收优惠政策内容");
			c42 = createCell(tWb, tRow, (short) 41, "零税率标识");
			c43 = createCell(tWb, tRow, (short) 42, "扣除额");
			c44 = createCell(tWb, tRow, (short) 43, "");
			c45 = createCell(tWb, tRow, (short) 44, "供应商");
			
			c1.setCellStyle(cStyleM_R);
			c2.setCellStyle(cStyleM_R);
			c3.setCellStyle(cStyleM_R);
			c4.setCellStyle(cStyleM_R);
			c5.setCellStyle(cStyleM_R);
			c6.setCellStyle(cStyleM_R);
			c7.setCellStyle(cStyleM_R);
			c8.setCellStyle(cStyleM_R);
			c9.setCellStyle(cStyleM_R);
			c10.setCellStyle(cStyleM_R);
			c11.setCellStyle(cStyleM_R);
			c12.setCellStyle(cStyleM_R);
			c13.setCellStyle(cStyleM_R);
			c14.setCellStyle(cStyleM_R);
			c15.setCellStyle(cStyleM_R);
			c16.setCellStyle(cStyleM_R);
			c17.setCellStyle(cStyleM_R);
			c18.setCellStyle(cStyleM_R);
			c19.setCellStyle(cStyleM_R);
			c20.setCellStyle(cStyleM_R);
			c21.setCellStyle(cStyleM_R);
			c22.setCellStyle(cStyleM_R);
			c23.setCellStyle(cStyleM_R);
			c24.setCellStyle(cStyleM_R);
			c25.setCellStyle(cStyleM_R);
			c26.setCellStyle(cStyleM_R);
			c27.setCellStyle(cStyleM_R);
			c28.setCellStyle(cStyleM_R);
			c29.setCellStyle(cStyleM_R);
			c30.setCellStyle(cStyleM_R);
			c31.setCellStyle(cStyleM_R);
			c32.setCellStyle(cStyleM_R);
			c33.setCellStyle(cStyleM_R);
			c34.setCellStyle(cStyleM_R);
			c35.setCellStyle(cStyleM_R);
			c36.setCellStyle(cStyleM_R);
			c37.setCellStyle(cStyleM_R);
			c38.setCellStyle(cStyleM_R);
			c39.setCellStyle(cStyleM_R);
			c40.setCellStyle(cStyleM_R);
			c41.setCellStyle(cStyleM_R);
			c42.setCellStyle(cStyleM_R);
			c43.setCellStyle(cStyleM_R);
			c44.setCellStyle(cStyleM_R);
			c45.setCellStyle(cStyleM_R);
			// c0.setCellStyle(cStyleM_R);
			short index = 2;
			if (vec != null && vec.size() > 0) {
				for (int k = 0; k < vec.size(); k++) {
					Vector vec1 = (Vector) vec.get(k);
					if (vec1 == null || !(vec1.size() > 0)) {
						break;
					}
					for (int j = 0; j < vec1.size(); j++) {
						String[] values = (String[]) vec1.get(j);

						// double productMonthMoney = 0;
						// double productMonthCount = 0;
						// double productInCount = 0;
						// double productInMoney = 0;

						// productMonthCount = Double.parseDouble(values[1]);
						// productMonthMoney = Double.parseDouble(values[2]);

						// productInCount = Double.parseDouble(values[3]);
						// productInMoney = Double.parseDouble(values[4]);
						// 創建一行
						tRow = tSheet.createRow((short) (index + 1));
						createCell(tWb, tRow, (short) 0, "");
						createCell(tWb, tRow, (short) 1, "");
						createCell(tWb, tRow, (short) 2, "");
						createCell(tWb, tRow, (short) 3, "");
						createCell(tWb, tRow, (short) 4, values[9] == null ? ""
								: values[9]);
						createCell(tWb, tRow, (short) 5,
								values[10] == null ? "" : values[10]);
						createCell(tWb, tRow, (short) 6,
								values[11] == null ? "" : values[11]);
						createCell(tWb, tRow, (short) 7,
								values[12] == null ? "" : values[12] + "");
						createCell(tWb, tRow, (short) 8, "");
						createCell(tWb, tRow, (short) 9, "");
						createCell(tWb, tRow, (short) 10, "");
						createCell(tWb, tRow, (short) 11, "");
						createCell(tWb, tRow, (short) 12, "");
						createCell(tWb, tRow, (short) 13, "");
						createCell(tWb, tRow, (short) 14, "");
						createCell(tWb, tRow, (short) 15, "");
						createCell(tWb, tRow, (short) 16, "");
						createCell(tWb, tRow, (short) 17,
								values[0] == null ? "" : values[0]);
						createCell(tWb, tRow, (short) 18,
								values[1] == null ? "" : values[1]);
						createCell(tWb, tRow, (short) 19,
								values[4] == null ? "" : values[4]);
						createCell(tWb, tRow, (short) 20,
								values[6] == null ? "" : values[6]);
						createCell2(tWb, tRow, (short) 21,
								values[7] == null ? "" : values[7]);
						createCell3(tWb, tRow, (short) 22,
								values[8] == null ? "" : values[8]);
						createCell2(tWb, tRow, (short) 23, "0.16");
						createCell(tWb, tRow, (short) 24, "");
						createCell(tWb, tRow, (short) 25, "");
						createCell(tWb, tRow, (short) 26, "");
						createCell(tWb, tRow, (short) 27, "");
						createCell(tWb, tRow, (short) 28, "");
						createCell(tWb, tRow, (short) 29, "");
						createCell(tWb, tRow, (short) 30, "");
						createCell(tWb, tRow, (short) 31, "");
						createCell(tWb, tRow, (short) 32, "");
						createCell(tWb, tRow, (short) 33, "");
						createCell(tWb, tRow, (short) 34, "");
						createCell(tWb, tRow, (short) 35, "");
						createCell(tWb, tRow, (short) 36, "");
						createCell(tWb, tRow, (short) 37,
								values[13] == null ? "" : values[13]);
						createCell(tWb, tRow, (short) 38,
								values[14] == null ? "" : values[14]);
						createCell(tWb, tRow, (short) 39, "");
						createCell(tWb, tRow, (short) 40, "");
						createCell(tWb, tRow, (short) 41, "");
						createCell(tWb, tRow, (short) 42, "");
						createCell(tWb, tRow, (short) 43, "");
						
						createCell(tWb, tRow, (short) 44, values[15]);
						/*
						 * createCell(tWb, tRow, (short) 3, values[11] == null ?
						 * "" : values[11]); createCell(tWb, tRow, (short) 4,
						 * values[12] == null ? "" : values[12]);
						 * createCell(tWb, tRow, (short) 5, values[13] == null ?
						 * "" : values[13]); createCell(tWb, tRow, (short) 6,
						 * values[14] == null ? "" : values[14]);
						 * createCell(tWb, tRow, (short) 7,
						 * StringUtil.showCount(values[15])); createCell(tWb,
						 * tRow, (short) 8,
						 * StringUtil.showCount(String.valueOf(productMonthCount
						 * ))); createCell(tWb, tRow, (short) 9,
						 * StringUtil.showPrice
						 * (String.valueOf(productMonthMoney))); createCell(tWb,
						 * tRow, (short) 10,
						 * StringUtil.showCount(String.valueOf(
						 * productInCount))); createCell(tWb, tRow, (short) 11,
						 * StringUtil
						 * .showPrice(String.valueOf(productInMoney)));
						 */
						index++;

					}
				}
				/** 输出EXCEL文件 开始 */
				fileName = fileName + ".xls";
				response.setContentType("application/ms-excel");
				response.addHeader("Content-disposition", "filename="
						+ fileName);
				out = response.getOutputStream();
				tWb.write(out);
				/** 输出EXCEL文件 结束 */
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			if (out != null) {
				try {
					out.close();
				} catch (IOException e) {

					e.printStackTrace();
				}
			}
		}
	}
}
